<template>
	<view>
		<image src="../../static/images/border.png" style="width: 780rpx; height: 90rpx;"></image>
		<view class="tit"> {{newsDetails.name}}</view>
		<view class="tex" style="width: 100%;overflow: hidden;" v-html="newsDetails.content" >
		</view>
		<view class="tit2">{{newsDetails.createBy}}<br />
			{{createTime}}<br />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newsDetails: null,
				createTime: {}
			}
		},
		onLoad(e) {
			uni.request({
					url: getApp().globalData.URL + "news/queryById?id=" + e.id,
					method: 'GET'
				})
				.then(data => { //data为一个数组，数组第一项为错误信息，第二项为返回数据
					var [error, res] = data;
					console.log(res.data);
					this.newsDetails = res.data;
					this.createTime = this.happenTimeFun(res.data.createTime);
				})
		},
		methods: {
			happenTimeFun(num) { //时间戳数据处理
				let date = new Date(num);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d; //天补0
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h; //小时补0
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m; //分钟补0
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s; //秒补0
				return y + '/' + MM + '/' + d; //年月日
			}
		}
	}
</script>
<style>
	.tex1 {
		color: #808080;
		font-size: 25rpx;
		margin: 20rpx 20rpx;
	}

	.fuj {
		text-indent: 2em;
	}

	.tit {
		margin: 10rpx 20rpx;
		height: 80rpx;
		height: auto;
		text-indent: 2em;
		font-size: 37rpx;
		text-align: center
	}

	.tit2 {
		text-align: right;
		margin: 20rpx 20rpx;
		font-size: 35rpx;
	}

	.tex {
		margin: 20rpx 20rpx;
		font-size: 30rpx;
		text-indent: 2em;
		display: block;
	}
</style>
